import { createApp } from 'vue'
import "font-awesome/css/font-awesome.min.css"
import { Toast } from "vant";
import "vant/lib/index.css";
import { isLogined } from "./utils/tools";
import {VueMasonryPlugin} from 'vue-masonry';
import mitt from 'mitt';
import router from "./router";
import "./style.css";
import App from './App.vue'
const app = createApp(App);
const emitter = mitt();
router.beforeEach((to, from, next) => {
  if (to.meta.needLogin) {
    if (isLogined()) {
      next();
    } else {
      Toast.fail("请先登录");
      next({
        name: "Login",
      });
    }
  } else {
    next();
  }
});
app.config.globalProperties.emitter = emitter;
app.use(VueMasonryPlugin);
app.use(router); // 使用路由插件
app.mount("#app");
